<?php
class Contact extends AppModel {

	var $name = 'Contact';
    var $primaryKey = 'contact_id';

  	/**
	 * Validation for contact
	 *
	 * @access public
	 * @var array Validations for model's table's fields
	 */
	var $validate = array(
		'email'=>array(
			array('rule' => array('between', 5, 30),'message'=>'1'),
			array('rule' => 'email','message'=>'1'),
			array('rule' =>array('minLength',1), 'message' => '1')
            ),
        );


    /**
     * Validating new comment whether same as before by email and description
     * usage in Comment Controller -> functino addComment()
     */
    function checkDuplicateContent($email,$description){
       $this->recursive = -1;
       $result = $this->find('count',array(
  			'conditions'=>array('AND'=>array('Contact.description'=>$description,'Contact.email'=>$email,"Contact.created >" => date('Y-m-d H:i:s', strtotime("-1 hour")))
       )));

       return $result;
    }
}
?>